package com.sfh.cpc.note.model;

import com.sfh.cpc.com.entity.RspBase;
import com.sfh.cpc.com.req.ReqMessage;
import com.sfh.lib.event.RxBusEventManager;
import com.sfh.lib.exception.HandleException;
import com.sfh.lib.mvvm.service.BaseViewModel;
import com.sfh.lib.rx.IResult;

/**
 * 功能描述: TODO
 *
 * @author SunFeihu 孙飞虎
 * @date 2018/8/29
 */
public class NoteAddMsg extends BaseViewModel {

    public void addMessage(final ReqMessage req) {

        this.execute(true,req, new IResult<RspBase>() {
            @Override
            public void onSuccess(RspBase o) throws Exception {
                if (o.success()) {
                    setValue("onSuccess");
                    RxBusEventManager.postEvent(req);
                } else {
                    showToast(o.getMsg());
                }
            }

            @Override
            public void onFail(HandleException e) {
                showToast(e.getMsg());
            }
        });

    }
}
